package action.bookinfo;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;

import bizlogic.bookinfo.BookInfoService;
import bizlogic.bookinfo.domain.BookInfo;

@WebServlet("/bookinfodetailaction")
public class BookInfoDetailAction extends HttpServlet
{
    private static final long serialVersionUID = 1L;
    BookInfoService bookInfoService = new BookInfoService();


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        detailBookInfo(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    /*
     * 功能需求：实例化一个Bookinfo实体，调用service层的相关方法，查看详细图书信息
     */
    public void detailBookInfo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String bookId = request.getParameter("data");
        BookInfo queryBookInfoByID = bookInfoService.queryBookInfoByID(bookId);
        String json = JSONObject.toJSONString(queryBookInfoByID);
        response.getWriter().write(json);
    }

}
